package top.hzy520;

import io.searchbox.client.JestClientFactory;
import io.searchbox.client.config.HttpClientConfig;
import io.searchbox.client.http.JestHttpClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import top.hzy520.common.constants.Parameters;

@SpringBootApplication
@EnableTransactionManagement
public class YuyuBuyServiceSearchApplication {
    @Autowired
    private Parameters parameters;

    public static void main(String[] args) {
        SpringApplication.run(YuyuBuyServiceSearchApplication.class, args);
    }

    @Bean
    public JestHttpClient getESClient(){
        JestClientFactory factory=new JestClientFactory();
        factory.setHttpClientConfig(new HttpClientConfig.Builder(
                "http://"+parameters.getEsHost())
                .multiThreaded(true)
                .readTimeout(5000)
                .build());
        JestHttpClient client= (JestHttpClient) factory.getObject();
        return client;
    }
}
